/***********************************************
 *				MochitoSockedServer.java
 *				------------
 *
 *	Author:  		bin04017
 *	Created:		19.01.2007
 *	Last modifed:	19.01.2007
 *	Description:	MochitoSockedServer.java is for
 *
 ************************************************/
package mochito.serverSide;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import mochito.tranferFactory.MochitoHost;

/**
 * @author bin04017
 * 
 */
public class MochitoSockedServer implements Runnable {

	private Socket service = null;

	private boolean running = true;
	
	public MochitoSockedServer(Socket service){
		this.service = service;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		try {
		    PrintWriter out = new PrintWriter(service.getOutputStream(), true);
		    BufferedReader in = new BufferedReader(
					    new InputStreamReader(
					    		service.getInputStream()));

		    String inputLine;
		
		    while(running ){
			    while ((inputLine = in.readLine()) != null) {
			    	//TODO WORK WITH INPUT		
			    }
		    }
		    out.close();
		    in.close();
		    service.close();

		} catch (IOException e) {
		    e.printStackTrace();
		}
	}

	public void stop(){
		setRunning(false);
	}
	/**
	 * @param running the running to set
	 */
	private void setRunning(boolean running) {
		this.running = running;
	}

}
